package org.darkforest.common.services.impl;

import org.darkforest.dao.mapper.SellerGroupMapper;
import org.darkforest.dao.mapper.SellerLogMapper;
import org.darkforest.dao.mapper.SellerMapper;
import org.darkforest.common.services.AccountService;
import org.darkforest.model.Seller;
import org.darkforest.model.SellerGroupWithBLOBs;
import org.darkforest.model.SellerLogSearchBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by valentina on 15/3/19.
 */
@Service("accountService")
public class AccountServiceImpl implements AccountService {
    @Autowired
    SellerMapper sellerMapper;
    @Autowired
    SellerGroupMapper sellerGroupMapper;
    @Autowired
    SellerLogMapper sellerLogMapper;

    public  List getAllSeller(){
        return sellerMapper.selectAllSeller();
    }
    public  List findSellerByCondition(Seller seller){
        return sellerMapper.findSellerByCondition(seller);
    }
    public int deleteSeller(int sellerId){
        return sellerMapper.deleteByPrimaryKey(sellerId);
    }

    @Override
    public int insertSelective(Seller seller) {
       return  sellerMapper.insertSelective(seller);
    }
    public int editSeller(Seller seller){
        return  sellerMapper.updateByPrimaryKeySelective(seller);
    }
    public int insertGroup(SellerGroupWithBLOBs group){
        return sellerGroupMapper.insertSelective(group);
    }

    public int editGroup(SellerGroupWithBLOBs group){
        return sellerGroupMapper.updateByPrimaryKeySelective(group);
    }
    public int deleteGroup(Integer groupId){
        return sellerGroupMapper.deleteByPrimaryKey(groupId);
    }

    @Override
    public void selectSellerLogListByCondition(SellerLogSearchBean page) {
        page.setResultList(sellerLogMapper.selectListByCondition(page));
    }
}
